I have an array that is created using:
Array changedAttrArray = create(1,6)
And when someone changes something in the dialog box (which contains 6 inputs), we save the values to this array. Now, I want to find out if, if the user clicks the "Close" button, there are any items saved to this array. How would I do that? I've tried using the sizeof function (sizeof(changedAttrArray)), but that gives me a value of 6.
Chris
Christopher Cote - Mon Sep 16 13:03:49 EDT 2019 |
Re: DXL - Determine number of items saved in multi-dimensional array Maybe the reason nobody has responded is because an array probably isn't the best thing to use for this situation? I personally never use them ...like ever. I would track the inputs in a skip list. I'm pretty sure you can store DBEs in a skip as the key and then in the callback for the inputs just update the skip with the new value for whichever DBE was called. |
Re: DXL - Determine number of items saved in multi-dimensional array davidcs - Wed Sep 18 09:25:07 EDT 2019 Maybe the reason nobody has responded is because an array probably isn't the best thing to use for this situation? I personally never use them ...like ever. I would track the inputs in a skip list. I'm pretty sure you can store DBEs in a skip as the key and then in the callback for the inputs just update the skip with the new value for whichever DBE was called. Now that you've brought up the idea of the skip list, I agree. The code I was working on was created by a former intern with us here and he had used the Arrays, so I was trying to keep things as close to the way he had first created it. The only issue I see with using skip lists is that they don't keep things in the order you put them in to the list, which you sometimes need. For example, if you add the following values in the order presented: "A", "E", "C", "B", "D" The skip list will automatically order them into "A", "B", "C", "D", "E".
Chris |
Re: DXL - Determine number of items saved in multi-dimensional array What I was thinking is if you are using separate DBEs you could track the value of the DBE in a skip using the DBE as the key and wouldn't have to worry about needing to keep track of the order. Really simple example, but show how it could be done for 1 DBE:
Skip lSkip = create()
DB reqBox = create "Edit Requirement"
string importance[] = {"Vital", "Useful",
"Convenient", "Useless"}
void callBack(DBE aDBE){
string lGet = get(aDBE)
if(find(lSkip, aDBE)){
delete(lSkip, aDBE)
put(lSkip, aDBE, lGet)
}else{
put(lSkip, aDBE, lGet)
}
// Debug showing the value was stored.
string lVal
for lVal in lSkip do{
print lVal "\n"
}
}
DBE reqImport = choice(reqBox, "Importance: ", importance, 2)
set(reqImport, callBack)
show reqBox
|